package pl.edu.agh.iosr.gamblingzone.commons;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;

import pl.edu.agh.iosr.gamblingzone.dao.QuoteDAO;
import pl.edu.agh.iosr.gamblingzone.model.Quote;
import pl.edu.agh.iosr.gamblingzone.utils.DAOFactory;

/**
 * The Class RandomQuoteAction.
 */
@Stateless
// @Scope(ScopeType.APPLICATION)
@Name("quotes")
public class RandomQuoteAction implements RandomQuote {

	/** The entity manager. */
	@PersistenceContext
	EntityManager entityManager;
	
	@In(required=true)
	DAOFactory dao;

	/** The quote dao. */
	private QuoteDAO quoteDAO;

	/** The quote. */
	@Out
	private Quote quote;

	/*
	 * (non-Javadoc)
	 * 
	 * @see pl.edu.agh.iosr.gamblingzone.action.RandomQuote#getQuote()
	 */
	public Quote getQuote() {
		
		quoteDAO = dao.getQuoteDAO();
		
		quote = quoteDAO.getRandomQuote();
		return quote;
	}
}